// 测试后端服务是否可用
import axios from 'axios';

async function testBackend() {
  const endpoints = [
    'http://localhost:8005/pay',
    'http://123.60.213.46:8000/pay',
    'http://localhost:8005/',
    'http://123.60.213.46:8000/'
  ];

  console.log('🔍 检查后端服务可用性...\n');

  for (const endpoint of endpoints) {
    try {
      console.log(`测试: ${endpoint}`);
      const response = await axios.get(endpoint, { timeout: 5000 });
      console.log(`✅ 成功: ${endpoint} - 状态码: ${response.status}`);
    } catch (error) {
      if (error.code === 'ECONNREFUSED') {
        console.log(`❌ 连接被拒绝: ${endpoint} - 服务未运行`);
      } else if (error.code === 'ENOTFOUND') {
        console.log(`❌ 域名未找到: ${endpoint} - 网络问题`);
      } else if (error.code === 'ETIMEDOUT') {
        console.log(`❌ 连接超时: ${endpoint} - 服务响应慢`);
      } else {
        console.log(`❌ 其他错误: ${endpoint} - ${error.message}`);
      }
    }
    console.log('');
  }
}

testBackend();

